package com.lmt.listener;

import org.apache.rocketmq.client.producer.LocalTransactionState;
import org.apache.rocketmq.client.producer.TransactionListener;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageExt;

/**
 * @Description: TODO
 * @Author: Amazing
 * @Date: 2022/7/25 20:09
 * @Version: 1.0
 */
public class MyTransactionListener implements TransactionListener {
    @Override
    public LocalTransactionState executeLocalTransaction(Message message, Object o) {
        // 进行业务判断
        System.out.println("执行了业务，保存了本地事务");
        return LocalTransactionState.COMMIT_MESSAGE;
    }

    @Override
    public LocalTransactionState checkLocalTransaction(MessageExt messageExt) {
        System.out.println("本地事务查询，提交成功！");
        return LocalTransactionState.COMMIT_MESSAGE;
    }
}
